import java.util.concurrent.CountDownLatch;

/**
 * Creat by TanLei
 * Description:
 * User:86183
 * Date:2022-06-16
 * Time:13:51
 */
public class Test5 {
    public static void main(String[] args) throws InterruptedException {
        //指定10个选手参赛
        CountDownLatch countDownLatch = new CountDownLatch(10);
        for(int i=0;i<10;i++){
            Thread t = new Thread(()->{
                try {
                    Thread.sleep(2);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("选手撞线了！"+Thread.currentThread().getName());
                countDownLatch.countDown();
            });
            t.start();
        }
        countDownLatch.await();
        System.out.println("比赛结束！");
    }
}
